<template>
	<view class="jobDetailPage">
		<view class="jobCard  mL15 mR15">
			<view class="u-3  line28">
				<text class=" font20 bold">{{info?.oddJobName}}</text>
				<u-tag :text="info?.izUrgentText" bg-color="#fff" class="jpTag" :color="'#FF0000'" :border-color="'#FF0000'"  v-show="info?.izUrgent==1"/>
				<u-tag v-if="info?.recruitmentCarefree&&info?.recruitmentCarefree.indexOf('10')>=0" text="用工无忧" bg-color="#EAF4FE" class="zgTag" :color="'#3291F8'" :border-color="'#EAF4FE'"
					 />				
				
			</view>
			<view class="flex alg-center mT5">
				<view class="jobTime">{{info?.jobBeginDatetime}}-{{info?.jobEndDatetime}}</view>
				<view class="jobTime">{{info?.salaryPaymentText}}</view>
				<view class="jobTime">招{{info?.oddJobUseNum}}人</view>
			</view>
			<view class="flex jst-between alg-center">
				<view class="">
					<text class="font24 u-red bold">{{info?.salary}}</text>
					<text class="u-red font14 bold">元</text>
				</view>
				<view class="font13 ua">
					发布于{{info?.timediffStr}}
				</view>
			</view>
			<view class="mT10 posBox">
				<view class="flex jst-between pT10">
					<view class="jobPos flex alg-center w80">
						<image class="posImg" :src="resources.posIcon" mode=""></image>
						<text class="mL5 font15 u-3" style="width:calc(100% - 50rpx)">{{info?.provinceName}}-{{info?.cityName}}-{{info?.areaName}}</text>
					</view>
					<view @click.stop="xf.openMap({lat:info?.latitude,lon:info?.longitude,address:info?.hopeWorkAddress})">
						<u-image :width="42" :height="42" :src="resources.route" mode=""></u-image>
					</view>
				</view>
				<view class="flex alg-center jst-between mT5">
					<view class="u-8bd font13 pL20 w80">
						{{info?.hopeWorkAddress}}
					</view>
					<view class="u-6 font13">
						{{info?.distance}}
					</view>
				</view>
			</view>

		</view>

		<view class="mL15 mR15 mT15">
			<view class="u-3 font18 bold mB15">职位要求</view>
			<view class="radius20 bgf pT15 pB15 pL15 pR15">
				<view class="font13 u-9">用工工期</view>
				<view class="u-3 font15 mT5">{{info?.jobBeginTime}}~{{info?.jobEndTime}}</view>
				<view class="font13 u-9 mT10">工作时间</view>
				<view class="u-3 font15 mT5">{{info?.jobBeginDatetime}}-{{info?.jobEndDatetime}}</view>
				<view class="font13 u-9 mT10">自带工具</view>
				<view class="u-3 font15 mT5">{{info?.izToolsText}}</view>
				<view class="font13 u-9 mT10">工作方式</view>
				<view class="u-3 font15 mT5">{{info?.workWayText}}</view>
			</view>
		</view>
		<view class="mL15 mR15 mT15">
			<view class="u-3 font18 bold mB15">职位详情</view>
			<view class="radius20 bgf pT15 pB15 pL15 pR15">
				<view class="font15 u-3 line32" v-if="info?.oddJobDescribe">
					{{info?.oddJobDescribe}}
				</view>
				<view v-else class="line50 t-center font13 u-8bd">
					暂无职位详情信息~~
				</view>
			</view>
		</view>
		<view class="mL15 mR15 mT15">
			<view class="u-3 font18 bold mB15">职位发布者</view>
			<view class="radius20 bgf pT15 pB15 pL15 pR15">
				<view class="flex pB15 jgGs mB15" v-if="info?.oddReleaseType==2" @click="xf.onlineUtils.route(`/pages/common/jggs/index?id=${info?.regulatoryId}`)">
					<u-image v-if="info?.regulatoryProfile" :width="90" :height="90" :src="xf.getImgUrl(info?.regulatoryProfile)" mode=""></u-image>
					<image v-else class="imgW90" :src="resources.defaultHeader" mode=""></image>
					<view class="companyInfo mL10">
						<view class="font16 bold">{{info?.regulatoryName}}</view>
						<view class="flex alg-center mT5">
							<image class="w24" src="/static/image/userImg/jg.png" mode=""></image>
							<text class="font13 u-6 mL5">监管认证</text>
						</view>
					</view>
				</view>
				
				<view class="flex" @click="jumpPersonDetail">
					<u-image :width="90" :height="90" v-if="info?.comOrUserProfile"
						:src="xf.getImgUrl(info?.comOrUserProfile)" mode=""></u-image>
					<image v-else class="imgW90" :src="resources.defaultHeader" mode=""></image>
					<view class="companyInfo mL10">
					
						<view class="flex jst-between alg-center">
							<view>
								<view class="font16 bold">{{info?.comOrUserName}}</view>
								<view class="flex alg-center mT5">
									<image v-if="info?.oddReleaseType==1" class="w24" :src="resources.qyrzLogo"
										mode=""></image>
									<image v-if="info?.oddReleaseType==2" class="w24" :src="resources.grrzLogo"
										mode=""></image>
									<text
										class="font13 u-6 mL5">{{info?.oddReleaseType==1?'企业招工认证':'个人招工认证'}}</text>
									<image class="w24 mL12" :src="resources.star" mode=""></image>
									<text class="u-yellow mL5 font15">{{info?.comOrUserScore}}</text>
								</view>
							</view>
							<view>
								<u-icon name="arrow-right" :size="28" :color="'#8d8d8d'"></u-icon>
							</view>
						</view>
						<view class="font15">在招职位 <text class="u-blue">{{info?.comOrUserWorkNum||0}}</text> 个</view>
					</view>

				</view>
			</view>

		</view>
		<view class="mL15 mR15 mT15">
			<view class="u-3 font18 bold mB15">安全提醒</view>
			<view class="radius20 bgf pT15 pB15 pL15 pR15">
				<view class="font15 u-3 line32">
					<u-parse :html="tx"></u-parse>
				</view>
			</view>
		</view>

		<view class="flex alg-center bottomFixed pT10 pB30 bgf font16 jst-around">
			<view class="flex flex-v jst-center alg-center" @click="chatJupm">
				<image class="imgW48" :src="resources.zxgt" mode=""></image>
				<view class="t-center font10">在线沟通</view>
			</view>
			<block v-if="info?.enrollStatus==1">
				<view class="pointer t-center u-f bg-blue2 w35 line50 radius30" @click="grabOpt">
					直接接单
				</view>
				<view class="pointer t-center u-f bg-blue1 w35 line50 radius30"
					@click="xf.onlineUtils.route(`/pages/common/devideJob/index?id=${info?.id}`)">
					派单给Ta
				</view>
			</block>
			<block v-else>
				<view class="pointer t-center u-f bg-gray w35 line50 radius30">
					直接接单
				</view>
				<view class="pointer t-center u-f bg-gray w35 line50 radius30">
					派单给Ta
				</view>
			</block>



		</view>
		<xfTipModal ref="tipModal"></xfTipModal>
	</view>
</template>

<script>
	import {
		grabDetail,
		rightNowBm
	} from '@/api/companyInterface/job.js'
	import {
		favorOpt,
		cancelFavor
	} from "@/api/userInterface/user.js"
	import {
		getXy
	} from "@/api/userInterface/user.js"
	import {
		getLocal
	} from "@/libs/map.js"
	export default {
		components: {

		},
		data() {
			return {
				loading: false,
				id: null,
				showModal: false,
				info: null,
				tx: null
			};
		},
		onLoad(e) {
			this.jobId = e.id;
			this.getDetail(this.jobId)
			this.getSalfe()
		},
		methods: {
			//打开聊天界面
			chatJupm(){
				let info={
					id: this.info.xfOddUserId,
					realName: this.info.comOrUserName,
					headImage: this.info.comOrUserProfile,
					online: false
				}
				this.chatStore.addFriend(info,'job',this.jobId)
			},
			//直接抢单
			grabOpt() {
				let that = this;
				that.$refs.tipModal.open({
					content: "您确定直接抢单吗?",
					btnText: "接单",
					showCancel:true,
					success: function() {
						rightNowBm({
							"xfOddjobInfoId": that.jobId,
							"xfOddjobInfoName": that.info.oddJobName
						}).then(res => {
							uni.showToast({
								icon:"none",
								title:"接单成功!",
								duration:2000
							})
							setTimeout(()=>{
								uni.navigateBack()
							},2000)
							
						}).catch(err => {
							
						})	
					}
				})


			},
			getSalfe() {
				getXy({
					agreement: 'AQTX'
				}).then(res => {
					this.tx = res.result.content
				})
			},
			async getDetail(id) {
				const {lat,lon} = await this.xf.getLatOrLon();
				grabDetail({
					infoId: this.jobId,
					latitude: lat,
					longitude:lon
				}).then(res => {
					this.info = res.result
				})
			},
			jumpPersonDetail() {
				let id=this.info.oddReleaseType==1?this.info.comId:this.info.xfOddUserId;
				uni.navigateTo({
					url: `/pages/common/personOrcompnayInfo/index?id=${id}&isPerson=${this.info?.oddReleaseType}`
				})
			},
		}
	};
</script>
<style lang="scss">
	page {
		min-height: 100%;
		background: linear-gradient(0deg, #F8FAFF, #EBF0FF);
	}
</style>
<style scoped lang="scss">
	.jobDetailPage{
		background: linear-gradient(0deg, #F8FAFF, #EBF0FF);
		padding-bottom: 220rpx;
	}
	.jgGs {
		border-bottom: 2rpx solid #F6F6F6;
	}

	.rightImg {
		width: 9rpx;
		height: 18rpx;
	}

	.phoneImg {
		width: 48rpx;
		height: 48rpx;
		margin: 0 auto;
	}

	.posBox {
		border-top: 2rpx solid #F6F6F6;
	}

	.companyInfo {
		width: calc(100% - 110rpx);
	}

	.jobCard {
		padding: 20rpx 30rpx;
		margin-bottom: 20rpx;
		background: #FFFFFF;
		border-radius: 20rpx;

		.jobName {
			width: 70%;
		}

		.jobLeft {
			max-width: 70%;
		}

		.jp {
			border: 2rpx solid #FF0000;
			border-radius: 10rpx;
			padding: 4rpx 10rpx;
			margin-right: 10rpx;
		}

		.jobTag {
			padding: 4rpx 10rpx;
			background: #F8F8F8;
			border-radius: 6rpx;
		}

		.jobMoney {
			word-break: keep-all;
		}

		.jobTime {
			color: #8D8D8D;
			font-size: 26rpx;
			margin-right: 10rpx;
			height: 44rpx;
			line-height: 44rpx;
			padding: 0 10rpx;
			background: #F8F8F8;
			border-radius: 6rpx;
			margin-top: 16rpx;
		}

		.posImg {
			width: 32rpx;
			height: 32rpx;
		}

		.posTxt {
			width: calc(100% - 42rpx);
			font-weight: 400;
			font-size: 26rpx;
			color: #8D8D8D;
		}

		.companyImg {
			width: 48rpx;
			height: 48rpx;
		}

		.rzImg {
			width: 24rpx;
			height: 24rpx;
		}

		.companyName {
			font-weight: 500;
			font-size: 30rpx;
			color: #333;
			margin-right: 10rpx;
			margin-left: 10rpx;
		}
	}
</style>